package com.buddy.summary.code.utils;


import org.apache.shiro.crypto.hash.Md5Hash;

public class MD5Util {

    /**
     * 对密码进行加盐的MD5加密
     *
     * @param userName
     * @param password
     * @return
     */
    public static String[] encryption(String userName, String password) {
        Integer index = userName.trim().length();
        String salt = userName.trim().charAt(index > 5 ? index - 4 : 0) + "";
        String pass = new Md5Hash(password.trim(), salt).toString();
        return new String[]{pass,salt};
    }
}
